<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        [v-cloak] {
            display: none
        }

        * {
            list-style: none;
            margin: 0;
            padding: 0
        }

        .container {
            width: 800px;
            border: 1px solid red;
            margin: 60px auto
        }

        .list {
            display: flex;
            margin: 10px 0 0 0;
            user-select: none;
        }

        .list li {
            padding: 10px 20px;
            cursor: pointer;
            margin: 0 10px;
        }

        .list li.active {
            color: #fff;
            background: orangered
        }

        .detail {
            display: flex;
            margin-top: 20px;
            user-select: none;
        }

        .detailLeft {
            width: 153px;
            height: 206px;
        }

        .detailRight {
            display: flex;
            flex-direction: column;
            justify-content: space-between
        }

        .detailRight li {
            padding: 10px;
        }

        .detailRight li .title {
            font-size: 18px;

        }

        .detailRight li .textStyle {
            font-size: 16px;
            color: #CCC
        }

        .detailRight li .textStyle>div {
            padding: 10px 0 0;
            font-size: 16px
        }

        .detailRight li .price {
            font-size: 16px;
            color: orangered
        }

        .detailRight li .number {
            color: orangered;
            font-size: 18px;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="container">
            <ul class="list">
                <li>城市</li>
                <li v-for="item in cityList" :key="item.id" @click="activeCityId=item.id"
                    :class="{active:activeCityId===item.id}">{{item.name}}</li>
            </ul>
            <ul class="list">
                <li>类型</li>
                <li v-for="item in typeList" :key="item.id" @click="activeTypeId=item.id"
                    :class="{active:activeTypeId===item.id}">{{item.name}}</li>
            </ul>
            <div class="detail" v-for="item in detailList" :key="item.id">
                <img class="detailLeft" :src="item.img" alt="">
                <ul class="detailRight">
                    <li>
                        <div class="title">【{{item.city}}】 {{item.artist}}{{item.title}}</div>
                        <div class="textStyle">
                            <div>艺人：{{item.artist}}</div>
                            <div>{{item.city}} | {{item.address}} </div>
                            <div>{{item.time}} </div>
                        </div>
                    </li>
                    <li> <span class="number">{{item.price}}</span> <span class="price">元</span> <span
                            class="textStyle "> &nbsp {{item.state| fmtstate}}</span> </li>
                </ul>
            </div>
        </div>


    </div>
    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
    <script>
        Math.rnd = (max, min = 0) => {
            return Math.round(Math.random() * (max - min)) + min
        }
        Vue.filter("fmtstate", val => {

            // if( val===0) { return "预售"}
            // else if( val===1){ return "售票中"}
            // else  return "售罄"

            switch (val) {
                case 0:
                    return '售票中'
                case 1:
                    return '售罄'
                case 2:
                    return '待开票'
                default:
                    return '其他'
            }
        })
        new Vue({
            el: "#app",
            data() {
                return {
                    activeCityId: 0,
                    activeTypeId: 0,
                    cityList: [{
                        id: 0,
                        name: "全部"
                    }, {
                        id: 1,
                        name: "南京"
                    }, {
                        id: 2,
                        name: "上海"
                    }, {
                        id: 3,
                        name: "广东"
                    }],
                    typeList: [{
                        id: 0,
                        name: "全部"
                    }, {
                        id: 1,
                        name: "演唱会"
                    }, {
                        id: 2,
                        name: "音乐会"
                    }, {
                        id: 3,
                        name: "戏剧"
                    }],
                    detailList: [{
                        id: 1,
                        img: "https://img.alicdn.com/bao/uploaded/i4/2251059038/O1CN01wlZbzW2GdSBZDYV69_!!0-item_pic.jpg_q60.jpg_.webp",
                        city: "杭州",
                        artist: "王力宏",
                        title: "“龙的传人2060”世界巡演杭州大莲花专场",
                        address: "杭州奥体博览中心主体育场",
                        time: "2019.08.10 周六 19:18",
                        price: "301-1601",
                        state: 0
                    }]
                }
            },
            // filters: {
            //     fmtstate: function (value) {
            //         console.log(value)
            //         if (value === 0) { return "预售" }
            //         else if (value === 1) { return "售票中" }
            //         else return "售罄"
            //     }
            // },

        })
    </script>
</body>

</html>